home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / asyam.zip / ASYNC.H < prev    next >
C/C++ Source or Header  |  1993-06-24  |  5KB  |  122 lines

  1. #ifndef     __async_h
  2. #define     __async_h
  3.  
  4. #define     NUMBEROFPORTS   4       // Number of COM ports available
  5.                                     // If this number is changed, and you plan
  6.                                     // on opening a com port greater than 4
  7.                                     // then you must create an ISR for it.
  8.                                     // See UART_ISR1..4 and you shouldn't have
  9.                                     // any problems.
  10.  
  11. #define     COM1            0       // COM port 1
  12. #define     COM2            1       // COM port 2
  13. #define     COM3            2       // COM port 3
  14. #define     COM4            3       // COM port 4
  15.  
  16. #define     UART_NONE       0       // No UART attached
  17. #define     UART_8250       1       // UART is an 8250
  18. #define     UART_16460      2       // UART is a 16460
  19. #define     UART_16550      3       // UART is a 16550
  20. #define     UART_16550A     4       // UART is a 16550A
  21.  
  22. #define     HSHAKE_NONE     0       // Handshaking:  None
  23. #define     HSHAKE_XONXOFF  1       // Handshaking:  XON/XOFF
  24.  
  25. #define     TXBUFSIZE       2048    // Transmit Buffer Size
  26. #define     RXBUFSIZE       2048    // Receive Buffer Size
  27.  
  28. #define     BASE            0       // Base (No real reason to have this)
  29. #define     IER             1       // Interrupt Enable Register
  30. #define     IIR             2       // Interrupt Identification Register
  31. #define     FCR             2       // 16550 FIFO Control Register
  32. #define     LCR             3       // Line Control Register
  33. #define     MCR             4       // Modem Control Register
  34. #define     LSR             5       // Line Status Register
  35. #define     MSR             6       // Modem Status Register
  36. #define     SCRATCH         7       // Scratch Pad (Is this ever used?)
  37.  
  38. #define     MCR_DTR         0x01    // DTR
  39. #define     MCR_RTS         0x02    // RTS
  40. #define     MCR_OUT1        0x04    // OUT1
  41. #define     MCR_OUT2        0x08    // OUT2
  42. #define     MCR_LOOPBACK    0x10    // Loopback
  43.  
  44. #define     LCR_PNONE       0       // None
  45. #define     LCR_PODD        8       // Odd
  46. #define     LCR_PEVEN       24      // Even
  47. #define     LCR_PMARK       40      // Mark
  48. #define     LCR_PSPACE      56      // Space
  49.  
  50. struct  async_portS {
  51.     int     port_open;
  52.  
  53.     void    interrupt (*oldISR)();
  54.  
  55.     char    *txbuf;
  56.     int     txhead, txtail;
  57.     int     txbuflength;
  58.  
  59.     char    *rxbuf;
  60.     int     rxhead, rxtail;
  61.     int     rxbuflength;
  62.  
  63.     int     overrun_errors;
  64.     int     parity_errors;
  65.     int     framing_errors;
  66.  
  67.     int     uart_type;
  68.  
  69.     int     handshaking;                    // Not yet implemented
  70. };
  71.  
  72. // setuart.c        -- UART setup routines
  73. void    set_UART_port(int comport, int value);
  74. void    set_UART_int(int comport, int value);
  75. void    set_UART_onmask(int comport, int value);
  76. void    set_UART_offmask(int comport, int value);
  77. int     set_parity(int comport, int parity);
  78. int     set_stopbits(int comport, int stopbits);
  79. int     set_wordlength(int comport, int wordlength);
  80. int     set_baudrate(int comport, long baudrate);
  81. void    set_handshaking(int comport, int status);
  82.  
  83. // detect.c         -- Various detecting routines: needs work
  84. int     async_detect_uart(int comport);
  85. int     async_detect_irq(int comport);
  86.  
  87. // isr.c            -- ISR setup routines, and the actual ISR's themselves
  88. void    init_ISR(int comport);
  89. void    deinit_ISR(int comport);
  90.  
  91. // fifo.c           -- FIFO routines: needs work
  92. int     init_fifo(int comport, int enable);
  93.  
  94. // async.c          -- Async setup routines
  95. int     open_port(int comport, long baudrate, int parity, int stopbits, int wordlength);
  96. int     close_port(int comport, int rts, int dtr);
  97.  
  98. // line.c           -- Line control/monitoring routines: needs work
  99. int     async_LCR(int comport);
  100. int     async_MCR(int comport);
  101. int     async_LSR(int comport);
  102. int     async_MSR(int comport);
  103. int     async_DTR_status(int comport);
  104. int     async_RTS_status(int comport);
  105. void    async_set_DTR(int comport, int status);
  106. void    async_set_RTS(int comport, int status);
  107.  
  108. // asyio.c          -- IO/Buffer routines: needs work
  109. int     async_putch_timeout(int comport, char c, long timeout);
  110. void    async_putch(int comport, char c);
  111. void    async_puts(int comport, char *s);
  112. int     async_putblock_timeout(int comport, const char *block, int size, long timeout);
  113. void    async_putblock(int comport, const char *block, int size);
  114. int     async_ready(int comport);
  115. char    async_getch(int comport);
  116. int     async_getblock(int comport, char *block, int size);
  117. char    async_peek(int comport);
  118. void    async_flushrx(int comport);
  119. void    async_flushtx(int comport);
  120.  
  121. #endif
  122.